	clear matrix 
	clear
	set more off
	set seed 123456789
	capture log close
	log using "C:\Users\Patron\OneDrive - UW-Madison\Graduate School\Academics\Fall 2020\PA 888 Social Policy\SP\Analysis Feb 2021\Analysis for 2018\Prepsm\Childdelivery\Log_delivery_prepsm.log", replace  // created a new log file 
	
	cd "C:\Users\Patron\OneDrive - UW-Madison\Graduate School\Academics\Fall 2020\PA 888 Social Policy\SP\Analysis Feb 2021\Analysis for 2018\Prepsm\Childdelivery"  // setting the current directory
	clear
	
	use "C:\Users\Patron\OneDrive - UW-Madison\Graduate School\Academics\Fall 2020\PA 888 Social Policy\SP\PBS Processed Data\All provinces and regions\1314 and 1819 Combined Feb 2021\prepsm_delivery_location_till_2018_vf.dta", replace
	
	
	
	keep if birth_year >= 2011
	keep if birth_year <= 2018
	
	keep if population_halves == 1
	
	tab treat
	
	
*****data for common trend assumption graph	*******

tabstat location_of_birth if treat == 1, by(birth_year)
tabstat location_of_birth if treat == 0, by(birth_year)

tab birth_year

*******testing common trend assumption via regression***************

gen time_trend = birth_year - 2011
gen inter_trend = time_trend*treat

local outputfile_common_trend commontrend_reg_bottom1.xls
set seed 12345678

bootstrap, reps(200): reg location_of_birth treat time_trend inter_trend birth_sequence hh_head_gender head_employment_status head_highest_grade hh_annual_income hh_annual_transfers hh_annual_exp_food_nondurables hh_annual_exp_durables hh_size dwelling_type occupancy_status distance_to_drinking_water drainage_sewerage_connection garbage_hh garbage_neighborhood drinking_water_source if time == 0, cluster(district) robust
outreg2 using `outputfile_common_trend'


***********summary table for DD for delivery location***********

ttest location_of_birth if treat == 1, by(time)
ttest location_of_birth if treat == 0, by(time)

local outputfile_dd_summary DD_child_delivery_summary_table.xls
set seed 123456789
bootstrap, reps(200): reg location_of_birth time treat did_estimator, cluster(district) robust
outreg2 using `outputfile_dd_summary' 


//creating dummy variable for each year for year fixed effects
 xi i.birth_year


*********DiD Estimations Tables for delivery location**************

local outputfile_dd_estimations did_delivery_bottom1.xls
set seed 123456789
bootstrap, reps(200): reg location_of_birth time treat did_estimator, cluster(district) robust
outreg2 using `outputfile_dd_estimations'

set seed 123456789
bootstrap, reps(200): reg location_of_birth time treat did_estimator _Ibirth_yea*, cluster(district) robust
outreg2 using `outputfile_dd_estimations'

set seed 123456789
bootstrap, reps(200): reg location_of_birth time treat did_estimator birth_sequence hh_head_gender head_employment_status head_highest_grade hh_annual_income hh_annual_transfers hh_annual_exp_food_nondurables hh_annual_exp_durables hh_size dwelling_type occupancy_status distance_to_drinking_water drainage_sewerage_connection garbage_hh garbage_neighborhood drinking_water_source _Ibirth_yea*, cluster(district) robust
outreg2 using `outputfile_dd_estimations'





********testing for distance to pseudo treatment variable drinking water***********


**********DiD Estimations*******************

local outputfile_pseudo_dd did_pseudo_drinkingwater.xls
set seed 123456789
bootstrap, reps(200): reg distance_to_drinking_water time treat did_estimator, cluster(district) robust
outreg2 using `outputfile_pseudo_dd'

set seed 123456789
bootstrap, reps(200): reg distance_to_drinking_water time treat did_estimator _Ibirth_yea*, cluster(district) robust
outreg2 using `outputfile_pseudo_dd'

set seed 123456789
bootstrap, reps(200): reg distance_to_drinking_water time treat did_estimator hh_head_gender head_employment_status head_highest_grade hh_annual_income hh_annual_transfers hh_annual_exp_food_nondurables hh_annual_exp_durables hh_size dwelling_type occupancy_status drainage_sewerage_connection garbage_hh garbage_neighborhood drinking_water_source _Ibirth_yea*, cluster(district) robust
outreg2 using `outputfile_pseudo_dd'





*****testing for pseudo treatment variable grabage collection from hh*******

local outputfile_pseudo2_dd did_pseudo2_garbage.xls
set seed 123456789
bootstrap, reps(200): reg garbage_hh time treat did_estimator, cluster(district) robust
outreg2 using `outputfile_pseudo2_dd'

set seed 123456789
bootstrap, reps(200): reg garbage_hh time treat did_estimator _Ibirth_yea*, cluster(district) robust
outreg2 using `outputfile_pseudo2_dd'

set seed 123456789
bootstrap, reps(200): reg garbage_hh time treat did_estimator hh_head_gender head_employment_status head_highest_grade hh_annual_income hh_annual_transfers hh_annual_exp_food_nondurables hh_annual_exp_durables hh_size dwelling_type occupancy_status distance_to_drinking_water drainage_sewerage_connection garbage_neighborhood drinking_water_source _Ibirth_yea*, cluster(district) robust
outreg2 using `outputfile_pseudo2_dd'



******************************************************************************************






********************for neonatal care and postnatal care*******************************


*******prenatal**********

ttest prenatal_care if time == 0, by(treat)

*******testing common trend assumption via regression***************


local outputfile_common_trend commontrend_prepost_natal.xls
set seed 12345678

bootstrap, reps(200): reg prenatal_care treat time_trend inter_trend birth_sequence hh_head_gender head_employment_status head_highest_grade hh_annual_income hh_annual_transfers hh_annual_exp_food_nondurables hh_annual_exp_durables hh_size dwelling_type occupancy_status distance_to_drinking_water drainage_sewerage_connection garbage_hh garbage_neighborhood drinking_water_source if time == 0, cluster(district) robust
outreg2 using `outputfile_common_trend'




***********did estimations******************
local outputfile_dd_estimations did_prepost_natal.xls
set seed 123456789
bootstrap, reps(200): reg prenatal_care time treat did_estimator, cluster(district) robust
outreg2 using `outputfile_dd_estimations'

set seed 123456789
bootstrap, reps(200): reg prenatal_care time treat did_estimator _Ibirth_yea*, cluster (district) robust
outreg2 using `outputfile_dd_estimations'

set seed 123456789
bootstrap, reps(200): reg prenatal_care time treat did_estimator birth_sequence hh_head_gender head_employment_status head_highest_grade hh_annual_income hh_annual_transfers hh_annual_exp_food_nondurables hh_annual_exp_durables hh_size dwelling_type occupancy_status distance_to_drinking_water drainage_sewerage_connection garbage_hh garbage_neighborhood drinking_water_source _Ibirth_yea*, cluster(district) robust
outreg2 using `outputfile_dd_estimations'



*******postnatal******

*******testing common trend assumption via regression***************


local outputfile_common_trend commontrend_prepost_natal.xls
set seed 12345678

bootstrap, reps(200): reg postnatal_care_in_six_weeks treat time_trend inter_trend birth_sequence hh_head_gender head_employment_status head_highest_grade hh_annual_income hh_annual_transfers hh_annual_exp_food_nondurables hh_annual_exp_durables hh_size dwelling_type occupancy_status distance_to_drinking_water drainage_sewerage_connection garbage_hh garbage_neighborhood drinking_water_source if time == 0, cluster(district) robust
outreg2 using `outputfile_common_trend'




***********did estimations******************

local outputfile_dd_estimations did_prepost_natal.xls
set seed 123456789
bootstrap, reps(200): reg postnatal_care_in_six_weeks time treat did_estimator, cluster(district) robust
outreg2 using `outputfile_dd_estimations'

set seed 123456789
bootstrap, reps(200): reg postnatal_care_in_six_weeks time treat did_estimator _Ibirth_yea*, cluster (district) robust
outreg2 using `outputfile_dd_estimations'

set seed 123456789
bootstrap, reps(200): reg postnatal_care_in_six_weeks time treat did_estimator birth_sequence hh_head_gender head_employment_status head_highest_grade hh_annual_income hh_annual_transfers hh_annual_exp_food_nondurables hh_annual_exp_durables hh_size dwelling_type occupancy_status distance_to_drinking_water drainage_sewerage_connection garbage_hh garbage_neighborhood drinking_water_source _Ibirth_yea*, cluster(district) robust
outreg2 using `outputfile_dd_estimations'





*******location of prenatal_care****

keep if location_prenatal_care == 1 | location_prenatal_care == 0

ttest location_prenatal_care if time == 0, by(treat)

*******testing common trend assumption via regression***************


local outputfile_common_trend commontrend_location_prepostcare.xls
set seed 12345678

bootstrap, reps(200): reg location_prenatal_care treat time_trend inter_trend birth_sequence hh_head_gender head_employment_status head_highest_grade hh_annual_income hh_annual_transfers hh_annual_exp_food_nondurables hh_annual_exp_durables hh_size dwelling_type occupancy_status distance_to_drinking_water drainage_sewerage_connection garbage_hh garbage_neighborhood drinking_water_source if time == 0, cluster(district) robust
outreg2 using `outputfile_common_trend'




************DiD estimations ******************

local outputfile_dd_estimations did_location_natalcare.xls
set seed 123456789
bootstrap, reps(200): reg location_prenatal_care time treat did_estimator, cluster(district) robust
outreg2 using `outputfile_dd_estimations'

set seed 123456789
bootstrap, reps(200): reg location_prenatal_care time treat did_estimator _Ibirth_yea*, cluster (district) robust
outreg2 using `outputfile_dd_estimations'

set seed 123456789
bootstrap, reps(200): reg location_prenatal_care time treat did_estimator birth_sequence hh_head_gender head_employment_status head_highest_grade hh_annual_income hh_annual_transfers hh_annual_exp_food_nondurables hh_annual_exp_durables hh_size dwelling_type occupancy_status distance_to_drinking_water drainage_sewerage_connection garbage_hh garbage_neighborhood drinking_water_source _Ibirth_yea*, cluster(district) robust
outreg2 using `outputfile_dd_estimations'


**********location of postnatal_care_in_six_weeks***

clear
clear matrix
	
	use "C:\Users\Patron\OneDrive - UW-Madison\Graduate School\Academics\Fall 2020\PA 888 Social Policy\SP\PBS Processed Data\All provinces and regions\1314 and 1819 Combined Feb 2021\prepsm_delivery_location_till_2018_vf.dta", replace

	keep if birth_year >= 2011
	keep if birth_year <= 2018
	
	keep if population_halves == 1
	
	tab postnatal_care_in_six_weeks
	keep if location_postnatal_care == 0 | location_postnatal_care == 1	
	
	
ttest location_postnatal_care if time == 0, by(treat)
estpost ttest location_postnatal_care if time == 0, by(treat)
esttab, wide nonumber mtitle("difference") star(* .10 ** .05 *** .01)


*******testing common trend assumption via regression***************
gen time_trend = birth_year - 2011
gen inter_trend = time_trend*treat

local outputfile_common_trend commontrend_location_prepostcare.xls
set seed 12345678

bootstrap, reps(200): reg location_postnatal_care treat time_trend inter_trend birth_sequence hh_head_gender head_employment_status head_highest_grade hh_annual_income hh_annual_transfers hh_annual_exp_food_nondurables hh_annual_exp_durables hh_size dwelling_type occupancy_status distance_to_drinking_water drainage_sewerage_connection garbage_hh garbage_neighborhood drinking_water_source if time == 0, cluster(district) robust
outreg2 using `outputfile_common_trend'


*************DiD Estimations********************	

//creating dummy variable for each year for year fixed effects
 xi i.birth_year
	
local outputfile_dd_estimations did_location_natalcare.xls
set seed 123456789
bootstrap, reps(200): reg location_postnatal_care time treat did_estimator, cluster(district) robust
outreg2 using `outputfile_dd_estimations'

set seed 123456789
bootstrap, reps(200): reg location_postnatal_care time treat did_estimator _Ibirth_yea*, cluster (district) robust
outreg2 using `outputfile_dd_estimations'

set seed 123456789
bootstrap, reps(200): reg location_postnatal_care time treat did_estimator birth_sequence hh_head_gender head_employment_status head_highest_grade hh_annual_income hh_annual_transfers hh_annual_exp_food_nondurables hh_annual_exp_durables hh_size dwelling_type occupancy_status distance_to_drinking_water drainage_sewerage_connection garbage_hh garbage_neighborhood drinking_water_source _Ibirth_yea*, cluster(district) robust
outreg2 using `outputfile_dd_estimations'







******************* for top 3rd of the population**********************************

clear matrix 
clear
set more off
set seed 123456789
capture log close

log using "C:\Users\Patron\OneDrive - UW-Madison\Graduate School\Academics\Fall 2020\PA 888 Social Policy\SP\Analysis Feb 2021\Analysis for 2018\Prepsm\Childdelivery\Log_delivery_prepsm_top3rd.log", replace  // created a new log file 
	
use "C:\Users\Patron\OneDrive - UW-Madison\Graduate School\Academics\Fall 2020\PA 888 Social Policy\SP\PBS Processed Data\All provinces and regions\1314 and 1819 Combined Feb 2021\prepsm_delivery_location_till_2018_vf.dta", replace
	
	
keep if birth_year >= 2011
keep if birth_year <= 2018
	
keep if population_tripartite == 3

*******testing common trend assumption via regression***************

gen time_trend = birth_year - 2011
gen inter_trend = time_trend*treat

local outputfile_common_trend commontrend_reg_top3rd.xls
set seed 12345678

bootstrap, reps(50): reg location_of_birth treat time_trend inter_trend birth_sequence hh_head_gender head_employment_status head_highest_grade hh_annual_income hh_annual_transfers hh_annual_exp_food_nondurables hh_annual_exp_durables hh_size dwelling_type occupancy_status distance_to_drinking_water drainage_sewerage_connection garbage_hh garbage_neighborhood drinking_water_source if time == 0, cluster(district) robust
outreg2 using `outputfile_common_trend'


//creating dummy variable for each year for year fixed effects
 xi i.birth_year

 *********DiD Estimations Tables for delivery location**************

local outputfile_dd_estimations dd_delivery_top3rd.xls
set seed 123456789
bootstrap, reps(50): reg location_of_birth time treat did_estimator, cluster(district) robust
outreg2 using `outputfile_dd_estimations'

set seed 123456789
bootstrap, reps(50): reg location_of_birth time treat did_estimator _Ibirth_yea*, cluster(district) robust
outreg2 using `outputfile_dd_estimations'

set seed 123456789
bootstrap, reps(200): reg location_of_birth time treat did_estimator birth_sequence hh_head_gender head_employment_status head_highest_grade hh_annual_income hh_annual_transfers hh_annual_exp_food_nondurables hh_annual_exp_durables hh_size dwelling_type occupancy_status distance_to_drinking_water drainage_sewerage_connection garbage_hh garbage_neighborhood drinking_water_source toilet_type _Ibirth_yea*, cluster(district) robust
outreg2 using `outputfile_dd_estimations'


log close



***************************************************************************

**************post psm dataset2**********************************


keep if district != 211 & district != 252 & district != 254 & district != 253 & district != 231 & district != 262 & district != 263 & district != 282 & district != 284 & district != 313 & district != 315 & district != 337 & district != 332 & district != 336 & district != 334 & district != 351 & district != 352 & district != 341 & district != 342 & district != 343 & district != 362 & district != 361


keep if birth_year >= 2011
	keep if birth_year <= 2018
	
	keep if population_halves == 1
	
	tab treat

	ttest location_of_birth if time == 0, by(treat)
	ttest prenatal_care if time == 0, by(treat)
	ttest postnatal_care_in_six_weeks if time == 0, by(treat)

	keep if location_postnatal_care == 1 | location_postnatal_care == 0
	ttest location_postnatal_care if time == 0, by(treat)

//creating dummy variable for each year for year fixed effects
 xi i.birth_year


*********DiD Estimations Tables for delivery location**************

local outputfile_dd_estimations did_delivery_bottom1.xls
set seed 123456789
bootstrap, reps(200): reg location_of_birth time treat did_estimator, cluster(district) robust
outreg2 using `outputfile_dd_estimations'

set seed 123456789
bootstrap, reps(200): reg location_of_birth time treat did_estimator _Ibirth_yea*, cluster(district) robust
outreg2 using `outputfile_dd_estimations'

set seed 123456789
bootstrap, reps(200): reg location_of_birth time treat did_estimator birth_sequence hh_head_gender head_employment_status head_highest_grade hh_annual_income hh_annual_transfers hh_annual_exp_food_nondurables hh_annual_exp_durables hh_size dwelling_type occupancy_status distance_to_drinking_water drainage_sewerage_connection garbage_hh garbage_neighborhood drinking_water_source _Ibirth_yea*, cluster(district) robust
outreg2 using `outputfile_dd_estimations'


















